<?php
namespace app\admin\model\log;
use think\Model;
use think\facade\Db;
use app\admin\common;
class Log extends Model {
	private $table_obj;
	protected $name="manager_log";
	
	
	public function insertLog($data_insert){
		common::delete("manager_log");
		return Db::name('manager_log')->strict(false)->insert($data_insert);
	}
	
	public function findLog($where,$field="*",$order="id desc"){
		$data=Db::name('manager_log')->where($where)->field($field)->order($order)->find();
		return $data;
	}
	public function insertAgentLog($_data){
		return Db::name("agent_settlement_log")->strict(false)->insertGetId($_data);
	}
	public function updateAgentLog($_up,$_where){
		return Db::name("agent_settlement_log")->where($_where)->update($_up);
	}
	public function findAgentLog($_where,$_field){
		return Db::name("agent_settlement_log")->where($_where)->field($_field)->find();
	}
	
	/**
	 * @Purpose 存储操作日志
	 */
	public static function insertRequestlog($data_insert){
		common::delete("admin_operations_log");
		return Db::name('admin_operations_log')->strict(false)->insert($data_insert);
	}
	
	public function findRequestLog($_where,$_field){
		return Db::name("admin_operations_log")->where($_where)->field($_field)->find();
	}
	
	public function selectRequestLog($_where,$_field,$_limit,$_order){
		$_data=Db::name("admin_operations_log")->where($_where)->field($_field)->limit(reset($_limit),end($_limit))->order($_order)->select();
		if(empty($_data)) return [];
		return $_data->toArray();
	}
	
	public function selectLog($where){
		
	}
	
	public function insertAppLogin($_data){
		return Db::name("app_login_log")->insert($_data,true);
	}
	
	public function insertAuditLog($_data){
		return Db::name("audit_log")->insert($_data,true);
	}
}
?>